package Thread.day01;

/**
 * 3个窗口卖票，总共100张，使用继承Thread的方法
 * 存在线程安全问题
 */
public class Exer2 {
    public static void main(String[] args) {
        window w1 = new window();
        window w2 = new window();
        window w3 = new window();
        w1.setName("窗口1");
        w2.setName("窗口2");
        w3.setName("窗口3");
        w1.start();
        w2.start();
        w3.start();
    }


}
class window extends Thread{
    private  static int ticket = 100;
    @Override
    public void run() {
        while(true){
            if(ticket>0){
                System.out.println(getName()+"卖出了票号为"+ticket);
                ticket--;
            }else {
                break;
            }
        }
    }
}
